Added tagged values to attributes based on the class' tagged values
This page was created by Lars.olofsson on 2017-10-25. Last edited by Edgar on 2025-08-31.
This EAL code will add the tagged value "PrimaryKey" to the attribute on the class that matches the class' primary key (which itself is stored as a tagged value).
TaggedValue.allInstances->
select(tv|tv.Tag='Eco.PrimaryKey')->
collect(tv | tv.ModelElement->safeCast(Class).Feature->filterOnType(Attribute)->select(a|a.TaggedValue->select(atv|(atv.Tag='Eco.ColumnName') and (atv.Value=tv.Value) )->notEmpty)->
collect(pka |
if pka.TaggedValue->select(atv| atv.Tag='Eco.ColumnName')->isEmpty then
let pktv = TaggedValue.Create in
(
pktv.Tag := 'PrimaryKey';
pktv.Value := 'true';
pka.TaggedValue.add(pktv)
);
true
else
false
endif
)
)
